import 'dart:convert';
import 'package:ichinesereader/models/book/BookLevel.dart';

BookRelease bookReleaseFromJson(String str) =>
    BookRelease.fromJson(json.decode(str));

String bookReleaseToJson(BookRelease data) => json.encode(data.toJson());

class BookRelease {
  BookRelease({
    this.status,
    this.message,
    this.result,
  });

  int? status;
  String? message;
  Map<String, List<BookReleaseItem>>? result;

  factory BookRelease.fromJson(Map<String, dynamic> json) => BookRelease(
        status: json["status"],
        message: json["message"],
        result: Map.from(json["result"]).map((k, v) =>
            MapEntry<String, List<BookReleaseItem>>(
                k,
                List<BookReleaseItem>.from(
                    v.map((x) => BookReleaseItem.fromJson(x))))),
      );

  Map<String, dynamic> toJson() => {
        "status": status,
        "message": message,
        "result": Map.from(result!).map((k, v) => MapEntry<String, dynamic>(
            k, List<dynamic>.from(v.map((x) => x.toJson())))),
      };
}

class BookReleaseItem {
  BookReleaseItem({
    this.imageLink,
    this.bookFeatures,
    this.level,
    this.series,
    this.description,
    this.textType,
    this.bookId,
    this.bookTitle,
    this.englishTitle,
  });

  String? imageLink;
  String? bookFeatures;
  Level? level;
  String? series;
  String? description;
  String? textType;
  String? bookId;
  String? bookTitle;
  String? englishTitle;

  factory BookReleaseItem.fromJson(Map<String, dynamic> json) =>
      BookReleaseItem(
        imageLink: json["imageLink"],
        bookFeatures: json["bookFeatures"],
        level: Level.fromJson(json["level"]),
        series: json["series"] == null ? null : json["series"],
        description: json["description"] == null ? null : json["description"],
        textType: json["textType"] == null ? null : json["textType"],
        bookId: json["bookId"],
        bookTitle: json["bookTitle"],
        englishTitle:
            json["englishTitle"] == null ? null : json["englishTitle"],
      );

  Map<String, dynamic> toJson() => {
        "imageLink": imageLink,
        "bookFeatures": bookFeatures,
        "level": level!.toJson(),
        "series": series == null ? null : series,
        "description": description == null ? null : description,
        "textType": textType == null ? null : textType,
        "bookId": bookId,
        "bookTitle": bookTitle,
        "englishTitle": englishTitle == null ? null : englishTitle,
      };
}
